<%--
  Created by IntelliJ IDEA.
  User: Roy
  Date: 2023/11/19
  Time: 15:13
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" isELIgnored="false" contentType="text/html;charset=UTF-8"%>
<html>
<head>
    <title>吐槽吧</title>
</head>
<body>
<h1>吐槽列表</h1>
<c:url var="prevUrl" value="/spittles/spittleList">
    <c:param name="currentPage" value="${currentPage - 1}" />
</c:url>

<c:url var="nextUrl" value="/spittles/spittleList">
    <c:param name="currentPage" value="${currentPage + 1}" />
</c:url>
<hr>
<table border="1">
    <tr>
        <td>id</td>
        <td>username</td>
        <td>message</td>
        <td>postedTime</td>
        <td>isChecked</td>
        <td>checkId</td>
        <td>checkTime</td>
        <td>审核</td>
        <td>删除</td>
    </tr>
    <c:forEach items="${spittleList}" var="spittle">
        <tr>
            <td>${spittle.id}</td>
            <td>${spittle.spitter.userName}</td>
            <td>${spittle.message}</td>
            <td>${spittle.postedTime}</td>
            <td>${spittle.isChecked}</td>
            <td>${spittle.checkId}</td>
            <td>${spittle.checkTime}</td>
            <%-- 如果未审核，则显示审核按钮 --%>
            <td>
                <c:if test="${spittle.isChecked == false}">
                    <form action="/spittles/checkSpittle" method="post">
                        <input type="hidden" name="spittleId" value="${spittle.id}" />
                        <button type="submit">审核</button>
                    </form>
                </c:if>
            </td>
            <td>
                <form action="/spittles/deleteSpittle" method="post">
                    <input type="hidden" name="spittleId" value="${spittle.id}" />
                    <button type="submit">删除</button>
                </form>
            </td>
        </tr>
    </c:forEach>
</table>
<hr>
<c:if test="${!noLess}">
    <a href="${prevUrl}">上一页</a>
</c:if>
<c:if test="${!noMore}">
    <a href="${nextUrl}">下一页</a>
</c:if>
<hr>
<a href="<c:url value="/mHome"/>">返回</a>
</body>
</html>
